<?php

namespace app\enterprise\model;

use app\model\TimeModel;

class Project extends TimeModel
{
    protected $table = 'sj_project';


    public static function getPage($where, $limit = 10)
    {

        $data = (new self)->where('status', '>', '0')
            ->where($where)
            ->order('id desc')
            ->paginate($limit);

        return $data;

    }

    /**
     * 新增记录
     */
    public function add($data)
    {
        return self::create($data);
    }


    /**
     * 编辑记录
     */
    public function edit($data)
    {
        return self::update($data, ['id' => $data['id'], 'company_id' => $data['company_id']]);
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'creator_id', 'id');
    }

}